import service from '@/utils/request'
// @Tags FileUploadAndDownload
// @Summary 分页文件列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取文件户列表"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fileUploadAndDownload/getFileList [post]
export const getFileList = (data) => {
  return service({
    url: '/fileUploadAndDownload/getFileList',
    method: 'post',
    data
  })
}

// @Tags FileUploadAndDownload
// @Summary 删除文件
// @Security ApiKeyAuth
// @Produce  application/json
// @Param data body dbModel.FileUploadAndDownload true "传入文件里面id即可"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"返回成功"}"
// @Router /fileUploadAndDownload/deleteFile [post]
export const deleteFile = (data, userName) => {
  return service({
    url: '/fileUploadAndDownload/deleteFile',
    method: 'post',
    data,
    headers: { 'userName': userName },
  })
}

/**
 * 编辑文件名
 * @param data
 * @returns {*}
 */
export const editFileName = (data) => {
  return service({
    url: '/fileUploadAndDownload/editFileName',
    method: 'post',
    data
  })
}
/**
 * 编辑文件名或者备注
 * @param data
 * @returns {*}
 */
export const editFileDesc = (data) => {
  return service({
    url: '/fileUploadAndDownload/editFileDesc',
    method: 'post',
    data
  })
}

/**
 * 根据地址获取图片
 * @param data
 * @returns {*}
 */
export const getImg = (url) => {
  return service({
    url: '/fileUploadAndDownload/getImg',
    method: 'get',
    params: { url }
  })
}

/**
 * 更改权限
 * @param data
 * @returns {*}
 */
export const changePermission = (data) => {
  return service({
    url: '/fileUploadAndDownload/changePermission',
    method: 'post',
    data
  })
}

/**
 * 新建文件夹
 * @param data
 * @returns {*}
 */
export const newFolder = (data) => {
  return service({
    url: "/fileUploadAndDownload/newFolder",
    method: 'post',
    data
  })
}
/**
 * 获取文件夹List
 * @param data
 * @returns {*}
 */
export const getDirList = (data) => {
  return service({
    url: "/fileUploadAndDownload/getDirList",
    method: 'post',
    data
  })
}

/**
 * 获取备份文件夹List
 * @param data
 * @returns {*}
 */
export const getBackupFileList = (data) => {
  return service({
    url: "/fileUploadAndDownload/getBackupFileList",
    method: 'post',
    data
  })
}

/**
 * 获取文件夹下的所有文件信息
 * @param params
 * @returns {*}
 */
export const getAllFileByDir = (dir, userName) => {
  return service({
    url: "/fileUploadAndDownload/getAllFileByDir",
    method: 'post',
    params: { dir, userName }
  })
}

/**
 * 获取备份文件数量
 * @param data
 * @returns {*}
 */
export const getBackupFileCount = (name) => {
  return service({
    url: "/fileUploadAndDownload/getBackupFileCount",
    method: 'post',
    params: {name}
  })
}